package config.xml;

import java.awt.BorderLayout;
import java.awt.ComponentOrientation;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Toolkit;
import java.io.IOException;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingConstants;

public class sets extends JFrame {

	private static final long serialVersionUID = 1L;

	private JPanel jContentPane = null;

	private JPanel jPanel = null;

	private JPanel jPanel2 = null;

	private JLabel jLabel1 = null;

	private JTextField jTextField = null;

	private JPanel jPanel3 = null;

	private JPanel jPanel4 = null;

	private JLabel jLabel2 = null;

	private JTextField jTextField1 = null;

	private JPanel jPanel1 = null;

	private JPanel jPanel5 = null;

	private JPanel jPanel6 = null;

	private JButton jButton = null;

	private JButton jButton1 = null;

	private JButton jButton2 = null;

	private JLabel jLabel = null;

	private JTextField jTextField2 = null;

	file f = new file();
//	boolean bproduct = true;
//	boolean brun = false;

	/**
	 * This is the default constructor
	 */
	public sets() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		this.setSize(283, 254);
		this.setResizable(false);
		this.setContentPane(getJContentPane());
		this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		this.setTitle("MybatisHelper");
	}

	/**
	 * This method initializes jContentPane
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jContentPane = new JPanel();
			jContentPane.setLayout(new FlowLayout());
			jContentPane
					.setBorder(BorderFactory.createEmptyBorder(30, 0, 0, 0));
			jContentPane.add(getJPanel(), null);
			jContentPane.add(getJPanel3(), null);
			jContentPane.add(getJPanel1(), null);
			jContentPane.add(getJPanel5(), null);
		}
		return jContentPane;
	}

	/**
	 * This method initializes jPanel
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanel() {
		if (jPanel == null) {
			jPanel = new JPanel();
			jPanel.setLayout(new BorderLayout());
			jPanel.setPreferredSize(new Dimension(300, 40));
			jPanel.add(getJPanel2(), BorderLayout.CENTER);
		}
		return jPanel;
	}

	/**
	 * This method initializes jPanel2
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanel2() {
		if (jPanel2 == null) {
			jLabel1 = new JLabel();
			jLabel1.setText("用户名：");
			jLabel1.setHorizontalAlignment(SwingConstants.RIGHT);
			jLabel1.setPreferredSize(new Dimension(60, 30));
			jPanel2 = new JPanel();
			jPanel2.setLayout(new FlowLayout());
			jPanel2.setPreferredSize(new Dimension(160, 40));
			jPanel2.add(jLabel1, null);
			jPanel2.add(getJTextField(), null);
		}
		return jPanel2;
	}

	/**
	 * This method initializes jTextField
	 * 
	 * @return javax.swing.JTextField
	 */
	private JTextField getJTextField() {
		if (jTextField == null) {
			jTextField = new JTextField();
			jTextField.setPreferredSize(new Dimension(130, 30));
		}
		return jTextField;
	}

	/**
	 * This method initializes jPanel3
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanel3() {
		if (jPanel3 == null) {
			jPanel3 = new JPanel();
			jPanel3.setLayout(new BorderLayout());
			jPanel3.setPreferredSize(new Dimension(300, 40));
			jPanel3.add(getJPanel4(), BorderLayout.CENTER);
		}
		return jPanel3;
	}

	/**
	 * This method initializes jPanel4
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanel4() {
		if (jPanel4 == null) {
			jLabel2 = new JLabel();
			jLabel2.setText("密   码：");
			jLabel2.setHorizontalAlignment(SwingConstants.RIGHT);
			jLabel2.setPreferredSize(new Dimension(60, 30));
			jPanel4 = new JPanel();
			jPanel4.setLayout(new FlowLayout());
			jPanel4.setPreferredSize(new Dimension(160, 40));
			jPanel4.add(jLabel2, null);
			jPanel4.add(getJTextField1(), null);
		}
		return jPanel4;
	}

	/**
	 * This method initializes jTextField1
	 * 
	 * @return javax.swing.JTextField
	 */
	private JTextField getJTextField1() {
		if (jTextField1 == null) {
			jTextField1 = new JTextField();
			jTextField1.setPreferredSize(new Dimension(130, 30));
		}
		return jTextField1;
	}

	/**
	 * This method initializes jTextField2
	 * 
	 * @return javax.swing.JTextField
	 */
	private JTextField getJTextField2() {
		if (jTextField2 == null) {
			jTextField2 = new JTextField();
			jTextField2.setPreferredSize(new Dimension(130, 30));
		}
		return jTextField2;
	}

	/**
	 * This method initializes jPanel1
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanel1() {
		if (jPanel1 == null) {
			jLabel = new JLabel();
			jLabel.setText("数据库名:");
			jLabel.setPreferredSize(new Dimension(60, 30));
			jPanel1 = new JPanel();
			jPanel1.setLayout(new FlowLayout());
			jPanel1.setPreferredSize(new Dimension(300, 40));
			jPanel1.add(jLabel, null);
			jPanel1.add(getJTextField2(), null);
		}
		return jPanel1;
	}

	/**
	 * This method initializes jPanel5
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanel5() {
		if (jPanel5 == null) {
			jPanel5 = new JPanel();
			jPanel5.setLayout(new BorderLayout());
			jPanel5.setPreferredSize(new Dimension(260, 50));
			jPanel5.add(getJPanel6(), BorderLayout.NORTH);
		}
		return jPanel5;
	}

	/**
	 * This method initializes jPanel6
	 * 
	 * @return javax.swing.JPanel
	 */
	private JPanel getJPanel6() {
		if (jPanel6 == null) {
			jPanel6 = new JPanel();
			jPanel6.setLayout(new FlowLayout(FlowLayout.RIGHT, 5, 5));
			jPanel6.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
			jPanel6.setPreferredSize(new Dimension(190, 50));
			jPanel6.add(getJButton(), null);
			jPanel6.add(getJButton1(), null);
			jPanel6.add(getJButton2(), null);
		}
		return jPanel6;
	}

	/**
	 * This method initializes jButton
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getJButton() {
		if (jButton == null) {
			jButton = new JButton();
			jButton.setPreferredSize(new Dimension(60, 35));
			jButton.setText("退出");
			jButton.addMouseListener(new java.awt.event.MouseAdapter() {
				public void mouseClicked(java.awt.event.MouseEvent e) {
					dispose();
				}
			});
		}
		return jButton;
	}

	/**
	 * This method initializes jButton1
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getJButton1() {
		if (jButton1 == null) {
			jButton1 = new JButton();
			jButton1.setPreferredSize(new Dimension(60, 35));
			jButton1.setText("运行");
			// jButton1.setEnabled(false);
			jButton1.addMouseListener(new java.awt.event.MouseAdapter() {
				public void mouseClicked(java.awt.event.MouseEvent e) {
					// if (brun == true) {
					f.cmd();
					// brun = false;
					// jButton1.setEnabled(false);
					// bproduct = true;
					// jButton2.setEnabled(true);
					// }
				}
			});
		}
		return jButton1;
	}

	/**
	 * This method initializes jButton2
	 * 
	 * @return javax.swing.JButton
	 */
	private JButton getJButton2() {
		if (jButton2 == null) {
			jButton2 = new JButton();
			jButton2.setPreferredSize(new Dimension(60, 35));
			jButton2.setText("生成");
			jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
				public void mouseClicked(java.awt.event.MouseEvent e) {
					// if (bproduct == true) {
					try {
						f.setUser(jTextField.getText());// 输入用户名
						f.setPassword(jTextField1.getText());// 输入密码
						f.setDBname(jTextField2.getText());// 要连接的数据库名称
						f.set();
						// bproduct = false;
						// jButton2.setEnabled(false);
						// brun = true;
						// jButton1.setEnabled(true);
					} catch (IOException e1) {
						e1.printStackTrace();
					}
				}
				// }
			});
		}
		return jButton2;
	}

	public static void main(String[] args) {
		sets s = new sets();
		Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
		Dimension frameSize = s.getSize();
		s.setLocation((screenSize.width - frameSize.width) / 2,
				(screenSize.height - frameSize.height) / 2);
		s.setVisible(true);
	}
}